<template>
  <h1>Child</h1>
  <p>{{ count }}</p>
  <button @click="handleClick">更新</button>
</template>

<script lang="ts">
export default {
  name: "Child",
  props: {
    count: {
      type: Number,
      required: true,
    },
  },
  emits: ["setCount"],
  setup(props, context) {
    console.log(props);
    console.log(props.count);

    console.log(context); // emit / attrs
    const handleClick = () => {
      // 触发自定义事件
      context.emit("setCount");
    };

    return {
      handleClick,
    };
  },
};
</script>

<style></style>
